<!--
 * @Author: wei_jt@ecidi.com
 * @Date: 2019-11-01 15:02:52
 * @LastEditors: wei_jt@ecidi.com
 * @LastEditTime: 2022-03-31 10:25:07
 * @Description: 无效路径统一跳转页
 -->
<template>
  <div class="wscn-http404">
    <div class="pic-404">
      <img
        class="pic-404__parent"
        :src="require(`@/assets/img/error/${type}.svg`)"
        :alt="type"
      >
      <img
        class="pic-404__child left"
        :src="img_404_cloud"
        alt="404"
      >
      <img
        class="pic-404__child mid"
        :src="img_404_cloud"
        alt="404"
      >
      <img
        class="pic-404__child right"
        :src="img_404_cloud"
        alt="404"
      >
    </div>
    <div class="text">
      <div class="tone">
        {{ LANG.TONE }}
      </div>
      <div class="desc">
        {{ LANG[`ERROR_${type}`] }}
      </div>
      <div class="tip">
        {{ LANG[`DESC_${type}`] }}
      </div>
      <div class="btn">
        <portal v-if="portals">
          <template v-slot="{ portal }">
            <fks-button class="fks-icon-toggle">
              {{ portal }}
            </fks-button>
          </template>
        </portal>
        <fks-button
          type="primary"
          style="margin-left: 10px"
          @click="back"
        >
          {{ LANG.GO_BACK }}
        </fks-button>
      </div>
    </div>
  </div>
</template>

<script>
import Portal from '@/components/Portal'
import img_404_cloud from '@/assets/img/error/404_cloud.png'
export default {
  components: {
    Portal
  },
  props: {
    type: {
      default: '404'
    }
  },
  data() {
    return {
      img_404_cloud
    }
  },
  computed: {
    portals() {
      return this.$store.state.portals.length
    }
  },
  methods: {
    back() {
      let path = '/home'
      if (
        this.$storage.get('access_token') == null ||
        this.$storage.get('redirectUrl') == '/home'
      ) {
        path = '/login'
      } else {
        this.$storage.set('redirectUrl', '/home')
      }
      location.href = location.href.replace('/' + this.type, path)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.wscn-http404 {
  display: flex;
  align-items: center;
  overflow: hidden;

  img {
    width: 100%;
  }

  .pic-404 {
    position: relative;

    &__child {
      position: absolute;

      &.left {
        width: 80px;
        opacity: 0;
        animation-name: cloudLeft;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-delay: 1s;
        animation-fill-mode: forwards;
      }

      &.mid {
        width: 46px;
        opacity: 0;
        animation-name: cloudMid;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-delay: 1.2s;
        animation-fill-mode: forwards;
      }

      &.right {
        width: 62px;
        opacity: 0;
        animation-name: cloudRight;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-delay: 1s;
        animation-fill-mode: forwards;
      }

      @keyframes cloudLeft {
        0% {
          top: 17px;
          left: 220px;
          opacity: 0;
        }

        20% {
          top: 33px;
          left: 188px;
          opacity: 1;
        }

        80% {
          top: 81px;
          left: 92px;
          opacity: 1;
        }

        100% {
          top: 97px;
          left: 60px;
          opacity: 0;
        }
      }

      @keyframes cloudMid {
        0% {
          top: 10px;
          left: 420px;
          opacity: 0;
        }

        20% {
          top: 40px;
          left: 360px;
          opacity: 1;
        }

        70% {
          top: 130px;
          left: 180px;
          opacity: 1;
        }

        100% {
          top: 160px;
          left: 120px;
          opacity: 0;
        }
      }

      @keyframes cloudRight {
        0% {
          top: 100px;
          left: 500px;
          opacity: 0;
        }

        20% {
          top: 120px;
          left: 460px;
          opacity: 1;
        }

        80% {
          top: 180px;
          left: 340px;
          opacity: 1;
        }

        100% {
          top: 200px;
          left: 300px;
          opacity: 0;
        }
      }
    }
  }

  .text {
    min-width: 500px;
    padding-left: 128px;

    .tone {
      margin-bottom: 20px;
      font-weight: bold;
      font-size: 24px;
      line-height: 32px;
      color: #0b4870;
      opacity: 0;
      animation-name: slide-up;
      animation-duration: 1s;
      animation-fill-mode: forwards;
    }

    .desc {
      margin: 16px 0 32px;
      font-size: 24px;
      line-height: 32px;
      color: #191919;
      opacity: 0;
      animation-name: slide-up;
      animation-duration: 1s;
      animation-delay: 0.1s;
      animation-fill-mode: forwards;
    }

    .tip {
      font-size: 16px;
      line-height: 20px;
      color: #555;
      opacity: 0;
      animation-name: slide-up;
      animation-duration: 1s;
      animation-delay: 0.2s;
      animation-fill-mode: forwards;
    }

    .btn {
      display: flex;
      justify-content: flex-end;
      margin-top: 48px;
      opacity: 0;
      animation-name: slide-up;
      animation-duration: 1s;
      animation-delay: 0.3s;
      animation-fill-mode: forwards;
    }

    @keyframes slide-up {
      0% {
        opacity: 0;
        transform: translateY(100px);
      }

      100% {
        opacity: 1;
        transform: translateY(0);
      }
    }
  }
}
</style>
